package com.topisv.tms.repository.task;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.task.DispatchOrderTask;

public interface DispatchOrderTaskDao extends PagingAndSortingRepository<DispatchOrderTask, Long>, JpaSpecificationExecutor<DispatchOrderTask> {

	/**
	 * 加载已锁定的数据
	 * @param ip
	 * @return List<DispatchOrderTask>
	 */
	@Query("select t from DispatchOrderTask t where dealIp = ?1 and dealStatus=1")
	List<DispatchOrderTask> findTask(String ip);
	
	
	/**
	 * 更新为已加载
	 * @param ip
	 * @param ids
	 * @return List<DispatchOrderTask>
	 */
	@Modifying
	@Query("update DispatchOrderTask t set t.dealStatus=2 where dealIp = ?1 and dealStatus=1 and id in ?2")
	void update(String ip,List<Long> ids);

}
